package com.suyang.syt.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.suyang.syt.dao.interfaces.WeixinQRcodeDao;
import com.suyang.syt.model.WeixinQRcode;

@Repository
public class WeixinQRcodeDaoImpl extends BaseDaoImpl<WeixinQRcode> implements WeixinQRcodeDao {

	@Override
	public void deletes(String ids) {
		String hql = " delete WeixinQRcode where id in (" + ids + ")";
		this.executeByHql(hql);
	}

	@Override
	public WeixinQRcode loadByScene(String scene) {
		try {
			long scene_id = Long.parseLong(scene);
			String hql = " from WeixinQRcode where scene_id = ? ";
			List<WeixinQRcode> list = this.list(hql, scene_id);
			if (list != null && list.size() == 1) {
				return list.get(0);
			}
		} catch (NumberFormatException e) {
			String hql = " from WeixinQRcode where scene_str = ?";
			List<WeixinQRcode> list = this.list(hql, scene);
			if (list != null && list.size() == 1) {
				return list.get(0);
			}
		}
		return null;
	}

}
